import javax.swing.text.rtf.RTFEditorKit;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] strings = new String[n];
        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            strings[i] = scanner.nextLine();
        }
        Solution solution = new Solution();
        System.out.println(solution.numberOfBeams(strings));
    }
}

class Solution {
    public int numberOfBeams(String[] bank) {
        int n = bank.length;
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            char[] arr = bank[i].toCharArray();
            for (int j = 0; j < arr.length; j++) {
                if(arr[j] == '1'){
                    num[i]++;
                }
            }
        }

        int res = 0;
        int a = num[0];
        for (int i = 1; i < n; i++) {
            if(num[i] != 0){
                res += a * num[i];
                a = num[i];
            }
        }
        return res;
    }
}